<extend name="Public/main" />
<block name="body">
	<div class="wrap jj">
		<include file="Public/nav"/>
		<div class="common-form">
			<form action="{:U('Admin/backup/import')}" method="post">
				<div class="table_list">
					<table width="100%" cellspacing="0" class="table_form">
						<thead>
							<tr>
								<td align="left">备份名称</td>
								<td>文件大小</td>
								<td>备份时间</td>
								<td>管理操作</td>
							</tr>
						</thead>
						<tbody>
						<volist name="backups" id="val">
							<tr class="collapsed">
								<td>
									<span style="padding-left: 20px" name="{$val.name}" class="expander"></span>
									{$val.name}
								</td>
								<td>{$val.total_size}kb</td>
								<td>{$val.date_str}</td>
								<td>
									<a href="{:u('Admin/backup/del_backup', array('backup'=>$val['name']))}">删除</a> | 
									<a href="{:u('Admin/backup/import', array('backup'=>$val['name']))}" >导入</a>
								</td>
							</tr>
							<volist name="val['vols']" id="vol">
								<tr parent="{$val.name}" class="hidden">
									<td>{$vol.file}</td>
									<td>{$vol.size}kb</td>
									<td>{$val.date_str}</td>
									<td>
										<a href="{:u('Admin/backup/download', array('backup'=>$val['name'], 'file'=>$vol['file']))}">下载</a>
									</td>
								</tr>
							</volist>
						</volist>
						</tbody>
					</table>
				</div>
			</form>
		</div> 
	</div>
</block>

<block name="style">
	<style type="text/css">
		.hidden{display:none;}
		.table_list tr.expanded td .expander{
			background: url(__STATIC__/images/admin/tv-collapsable.gif) center center no-repeat;
		}
		.table_list tr.collapsed td .expander{
			background: url(__STATIC__/images/admin/tv-expandable.gif) center center no-repeat;
		}
	</style>
</block>
<block name="script">
	<script>
		$(function() {
			$(".show_sub").click(function() {
				$(this).attr("src", function() {
					if (this.src == '__STATIC__/images/admin/tv-expandable.gif') {
						return '__STATIC__/images/admin/tv-collapsable.gif';
					} else {
						return '__STATIC__/images/admin/tv-expandable.gif';
					}
				});
				var sub_id = $(this).attr('sub');
				$("tr[parent='" + sub_id + "']").toggle();
			});
			$('.expander').toggle(function() {
				$(this).parent().parent().removeClass('collapsed').addClass('expanded');
				$('tr[parent="' + $(this).attr('name') + '"]').show();
			}, function() {
				$(this).parent().parent().removeClass('expanded').addClass('collapsed');
				$('tr[parent="' + $(this).attr('name') + '"]').hide();
			});
		});
	</script>
</block>
